<template>
  <div class="container" :style="{ backgroundImage: `url(${tourDetail.picture})` }">
    <van-nav-bar
      class="header"
      :border="false"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    >
      <template #right>
        <div><van-icon name="wap-nav" /> <span>更多巡演</span></div>
      </template>
    </van-nav-bar>

    <div class="description">
      <div class="left">
        <div class="cover">
          <img :src="tourDetail.picture" class="thumb" />
        </div>
      </div>
      <div class="right">
        <div class="title">{{ tourDetail.tagName }}</div>
        <div class="advertise">{{ tourDetail.advertise }}</div>

        <van-button plain hairline size="small" round class="follow"
          ><van-icon name="plus" /> 关注</van-button
        >
      </div>
    </div>

    <div class="tips">
      <van-icon name="down" />
      <span>下拉查看已结束演出</span>
    </div>

    <div class="site-list"></div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, computed } from 'vue'
import { fetchTourDetail, fetchTourSiteList } from '@/api/index.js'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
import { useStore } from '@/stores/index.js'
const store = useStore()

const tagId = computed(() => route.query.tourId)

// console.log('tagId:', tagId.value)

const tourDetail = reactive({
  tagId: '',
  tagName: '',
  tagDesc: '',
  picture: '',
  advertise: '',
  itemSortType: '',
})

const tourSites = ref([])

onMounted(async () => {
  await getTourDetail(tagId.value)

  await getTourSiteList(store.currentCity.cityId, tagId.value)
})

//返回前一页
const onClickLeft = () => {
  // console.log('返回前一页')
  router.go(-1)
}

// 进入巡演列表
const onClickRight = () => {
  console.log('进入巡演列表')
}

const getTourDetail = async (tagId) => {
  try {
    const { statusCode, data } = await fetchTourDetail(tagId)
    if (statusCode === 200) {
      tourDetail.tagId = data.tagId
      tourDetail.tagName = data.tagName
      tourDetail.tagDesc = data.tagDesc
      tourDetail.picture = data.picture
      tourDetail.advertise = data.advertise
      tourDetail.itemSortType = data.itemSortType
    }
  } catch (error) {
    console.error('获取巡演详情失败:', error)
  }
}

const getTourSiteList = async (cityId, tagId) => {
  try {
    const { statusCode, data } = await fetchTourSiteList(cityId, tagId)
    if (statusCode === 200) {
      tourSites.value = data
    }
  } catch (error) {
    console.error('获取巡演详情失败:', error)
  }
}
</script>

<style scoped lang="scss">
:deep(i.van-badge__wrapper.van-icon.van-icon-arrow-left.van-nav-bar__arrow) {
  color: #fff;
}

:deep(i.van-badge__wrapper.van-icon.van-icon-wap-nav) {
  color: #fff;
}

:deep(.van-button.follow) {
  background-color: transparent;
}

.container {
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;

  .header {
    background-color: transparent;
    position: relative;
    z-index: 2;
  }

  .description {
    color: #fff;
    display: flex;
    align-items: flex-start;
    position: relative;
    z-index: 1;
    gap: 20px;
    padding: 30px 15px;
    justify-content: flex-start;

    .left {
      .cover {
        width: 100px;
        height: 150px;
        border-radius: 8px;
        overflow: hidden;
        position: relative;

        .thumb {
          width: 100%;
          height: 100%;
          object-fit: cover;
          position: absolute;
          top: 0;
          left: 0;
        }
      }
    }

    .right {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 10px;

      .title {
        font-size: 18px;
        font-weight: 500;
      }

      .advertise {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.5);
        margin-bottom: 30px;
      }

      .follow {
        color: #fff;
        font-size: 14px;
        font-weight: 500;
      }
    }
  }

  .tips {
    color: rgba(255, 255, 255, 0.5);
    position: relative;
    z-index: 1;
    font-size: 12px;
    padding: 0 15px;
  }
}

.container::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100vh;
  top: 0;
  left: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.33) 31%);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  z-index: 0;
}
</style>
